<?php use_helper('Text') ?>
<?php use_helper('Slug') ?>
<div style="text-align:right;margin:10px;">
<a class="menu_action" href="<?php echo url_for('@creation_article'); ?>"><?php echo image_tag("Icons/menu_action/new.png", array("width" => 13,"height" => 13, "alt" => "icon")) ?> Créer un article</a>
</div>
<div class="title_section">Les articles disponibles <a class="menu_action" href="<?php echo url_for('@creation_article'); ?>">(Créer)</a></div>
<div class="section">
  <div class="nav_barre"><?php echo get_component('headers', 'pager', array('module' => "article", 'action' => "index", 'pager' => $pager,"optNbTotal" => false,"optImgNextPrev" => false)); ?></div>
  <ul class="titre_elem">
    <li class="inline" style="width: 55px"> Categorie </li>
    <li class="inline" style="width: 100px"> Disponible pour </li>
    <li class="inline" style="width: 20px"></li>
    <li class="inline" style="width: 325px"> Titre</li>
    <li class="inline" style="width: 50px"> Coms </li>
    <li class="inline" style="width: 95px"> Note </li>
  </ul>
  <?php $i = 0;foreach ($articles as $article): ?>
  <ul class="elem_on_section">
    
    <li class="inline" style="width: 55px"> <?php echo image_tag("Categories/".$article->getCategories()->getImg().".png", array("width" => 25,"height" => 25, "alt" => "pict", "title" => $article->getCategories()->getNom())) ?> </li>
    <li class="inline" style="width: 100px">
      <?php 
	  for($j = 0; $j < count($article["Assoplatform"]) && $j < 3; $j++):?>
      <a href="<?php echo url_for("search/platform?id=".$article["Assoplatform"][$j]["Platform"]["id"]) ?>"><?php echo image_tag("Platform/".$article["Assoplatform"][$j]["Platform"]["picture"], array("width" => 20,"height" => 20, "alt"=> $article["Assoplatform"][$j]["Platform"]["real_name"],"title" => $article["Assoplatform"][$j]["Platform"]["real_name"])) ?></a>
      <?php endfor;?>
    </li>
    <li class="inline"  style="width: 20px" title="
                        <?php if(count($article["Assoplatform"]) > 2):?>
                        	<?php foreach($article["Assoplatform"] as $assoPlat):?>
                            	<?php echo $assoPlat["Platform"]["name"]?>
                            <?php endforeach;?>
                        <?php endif;?>
                        ">
      <?php if(count($article["Assoplatform"]) > 2):?>
      >>
      <?php endif;?>
    </li>
    <li class="inline" style="width: 325px"> <a class="link_title" href="<?php echo url_for('@show_article_by_id?title='.sluggify($article["title"]).'&idarticles='.$article->getIdarticles()); ?>"><?php echo truncate_text($article->getTitle(),45,"...") ?></a> <span class='block tag'><?php echo image_tag("Icons/".$sf_context->getModuleName()."/bookmark.png", array("width" => 15,"height" => 15, "alt" => "pict")) ?>
      <?php foreach($article["Tags"] as $tag):?>
      <?php echo $tag["tag"] ?>
      <?php endforeach;?>
      </span> </li>
    
    <li class="inline" style="width: 50px"> <?php echo $nb_coms[$i] ?> </li>
    <li class="inline" style="width: 95px">
      <?php $total = 0;
			  $i = 0;
		foreach($article["Assoplatform"][0]["Notes"] as $note):
				$total += intval($note["note"]);
				$i++;
			endforeach;
			if($i > 0)
				$Moyenne = round($total / $i,2);
			else
				$Moyenne = "0";
		
		 ?>
      <div class="jRating" data="<?php echo $Moyenne ?>_<?php echo $article["Assoplatform"][0]["idassoplatform"] ?>">
    </li>
  </ul>
  <?php $i++;endforeach; ?>

  <div class="nav_barre"><?php echo get_component('headers', 'pager', array('module' => "article", 'action' => "index", 'pager' => $pager)); ?></div>
</div>
<?php echo "
<script>
$(document).ready(function(){ 
   // Call with options - exemple
   $('.jRating').jRating({
     step : false, // no step
     length : 5, // show 10 stars at the init
	 bigStarsPath : '".url_for("/images/Icons/stars.png")."',
	 smallStarsPath: '".url_for("/images/Icons/small.png")."',
	 phpPath: '".url_for("article/jrating")."', 
	 isDisabled: true
   });
});
</script>
";
?>
